package com.longge.wechat.controller.wx;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.longge.wechat.message.post.Music;
import com.longge.wechat.message.post.PostMusicMessage;
import com.longge.wechat.message.wxUtil.WeiXinUtil;



@Controller
public class PostMusicController {

	@RequestMapping(value = "/respMusic.do", method = RequestMethod.POST)
	protected void doPost2(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String content = "";
		String openId = (String) request.getAttribute("openId");
		PostMusicMessage pmm = new PostMusicMessage();
		pmm.setTouser(openId);
		pmm.setMsgtype("music");
		Music music = new Music();
		
		music.setDescription("这是客服发送音乐测试");
		music.setHqmusicurl("4444444");
		music.setMusicurl("5555555555");
		music.setThumb_media_id("6666666666");
		music.setTitle("客服发送音乐测试");
		
		pmm.setMusic(music);
		int result = WeiXinUtil.sendInfo(pmm);
		if(result == 1) {
			content = "发送音乐消息成功";
		}
		System.out.println(content);
	}
}
